import {ADD_LIST, CHANGE_VALUE,INIT_LIST} from "../constants/action-type";
import http from "../api/http"

function changeValue(value, name, age) {
    return {
        type: CHANGE_VALUE,
        value: value,
        name,
        age
    }
}

function addList(title) {
    return {
        type: ADD_LIST,
        value:{title}
    }
}

function initList () {
    return dispatch => {
        http.post("http://59.111.92.205:8088/api/cms/article/open/banner/list?pageSize=10&pageNum=1").then(res =>{
            if(res.data.code === 0) {
            console.log(res);
                // 进行数据的更新 因为返回数据是对象所以下面渲染时应该渲染对象中的属性
                dispatch({
                    type:INIT_LIST,
                    list:res.data.rows
                })
            }
        })
    }
}
export {
    changeValue,
    addList,
    initList
}